namespace SmartSoft.Lists
{
    using SmartSoft;
    using SmartSoft.Controls;
    using SmartSoft.ADP;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmNhDtEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblMa_Nh_Dt;
        private LabelControl lblNh_Cuoi_Dt;
        private LabelControl lblNh_Cuoi_Dt0;
        private LabelControl lblNh_Me_Dt;
        private LabelControl lblTen_Nh_Dt;
        private LabelControl lblTen_Nh_DtE;
        private TextControl txtMa_Nh_Dt;
        private TextOption txtNh_Cuoi_Dt;
        private TextSearch txtNh_Me_Dt;
        private TextControl txtTen_Nh_Dt;
        private TextControl txtTen_Nh_DtE;
        private TextOption txtNh_PhanTheoDV_Dt;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private TextControl txtTen_Nh_Me;

        public FormDmNhDtEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.txtMa_Nh_Dt = new SmartSoft.Controls.TextControl();
            this.lblMa_Nh_Dt = new SmartSoft.Controls.LabelControl();
            this.txtTen_Nh_Dt = new SmartSoft.Controls.TextControl();
            this.lblTen_Nh_Dt = new SmartSoft.Controls.LabelControl();
            this.txtTen_Nh_DtE = new SmartSoft.Controls.TextControl();
            this.lblTen_Nh_DtE = new SmartSoft.Controls.LabelControl();
            this.lblNh_Cuoi_Dt = new SmartSoft.Controls.LabelControl();
            this.txtNh_Cuoi_Dt = new SmartSoft.Controls.TextOption();
            this.txtNh_Me_Dt = new SmartSoft.Controls.TextSearch();
            this.txtTen_Nh_Me = new SmartSoft.Controls.TextControl();
            this.lblNh_Me_Dt = new SmartSoft.Controls.LabelControl();
            this.lblNh_Cuoi_Dt0 = new SmartSoft.Controls.LabelControl();
            this.txtNh_PhanTheoDV_Dt = new SmartSoft.Controls.TextOption();
            this.labelControl1 = new SmartSoft.Controls.LabelControl();
            this.labelControl2 = new SmartSoft.Controls.LabelControl();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 141);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.FirstFilter = "Type = \'NT1\'";
            this.txtMa_Loai1.Location = new System.Drawing.Point(123, 138);
            this.txtMa_Loai1.TabIndex = 7;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.FirstFilter = "Type = \'NT2\'";
            this.txtMa_Loai2.Location = new System.Drawing.Point(251, 138);
            this.txtMa_Loai2.TabIndex = 8;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.FirstFilter = "Type = \'NT3\'";
            this.txtMa_Loai3.Location = new System.Drawing.Point(379, 138);
            this.txtMa_Loai3.TabIndex = 9;
            // 
            // txtMa_Nh_Dt
            // 
            this.txtMa_Nh_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Nh_Dt.CheckTextSearched = false;
            this.txtMa_Nh_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Nh_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Nh_Dt.Location = new System.Drawing.Point(123, 28);
            this.txtMa_Nh_Dt.MaxLength = 32;
            this.txtMa_Nh_Dt.Name = "txtMa_Nh_Dt";
            this.txtMa_Nh_Dt.OldValue = null;
            this.txtMa_Nh_Dt.Size = new System.Drawing.Size(109, 20);
            this.txtMa_Nh_Dt.TabIndex = 1;
            this.txtMa_Nh_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nh_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Nh_Dt.Value = global::SmartSoft.ReportForms.FormVTH02BViewer.txtTen_Nh_Vt_Value;
            // 
            // lblMa_Nh_Dt
            // 
            this.lblMa_Nh_Dt.AutoSize = true;
            this.lblMa_Nh_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Nh_Dt.Location = new System.Drawing.Point(12, 31);
            this.lblMa_Nh_Dt.Name = "lblMa_Nh_Dt";
            this.lblMa_Nh_Dt.Size = new System.Drawing.Size(50, 14);
            this.lblMa_Nh_Dt.TabIndex = 4;
            this.lblMa_Nh_Dt.Text = "Mã nhóm";
            // 
            // txtTen_Nh_Dt
            // 
            this.txtTen_Nh_Dt.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nh_Dt.CheckTextSearched = false;
            this.txtTen_Nh_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTen_Nh_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_Dt.Location = new System.Drawing.Point(123, 50);
            this.txtTen_Nh_Dt.MaxLength = 128;
            this.txtTen_Nh_Dt.Name = "txtTen_Nh_Dt";
            this.txtTen_Nh_Dt.OldValue = null;
            this.txtTen_Nh_Dt.Size = new System.Drawing.Size(382, 20);
            this.txtTen_Nh_Dt.TabIndex = 3;
            this.txtTen_Nh_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Nh_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtTen_Nh_Dt.Value = global::SmartSoft.ReportForms.FormVTH02BViewer.txtTen_Nh_Vt_Value;
            // 
            // lblTen_Nh_Dt
            // 
            this.lblTen_Nh_Dt.AutoSize = true;
            this.lblTen_Nh_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTen_Nh_Dt.Location = new System.Drawing.Point(12, 53);
            this.lblTen_Nh_Dt.Name = "lblTen_Nh_Dt";
            this.lblTen_Nh_Dt.Size = new System.Drawing.Size(54, 14);
            this.lblTen_Nh_Dt.TabIndex = 4;
            this.lblTen_Nh_Dt.Text = "Tên nhóm";
            // 
            // txtTen_Nh_DtE
            // 
            this.txtTen_Nh_DtE.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Nh_DtE.CheckTextSearched = false;
            this.txtTen_Nh_DtE.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtTen_Nh_DtE.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_DtE.Location = new System.Drawing.Point(123, 72);
            this.txtTen_Nh_DtE.MaxLength = 128;
            this.txtTen_Nh_DtE.Name = "txtTen_Nh_DtE";
            this.txtTen_Nh_DtE.OldValue = null;
            this.txtTen_Nh_DtE.Size = new System.Drawing.Size(382, 20);
            this.txtTen_Nh_DtE.TabIndex = 4;
            this.txtTen_Nh_DtE.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Nh_DtE.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtTen_Nh_DtE.Value = global::SmartSoft.ReportForms.FormVTH02BViewer.txtTen_Nh_Vt_Value;
            // 
            // lblTen_Nh_DtE
            // 
            this.lblTen_Nh_DtE.AutoSize = true;
            this.lblTen_Nh_DtE.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTen_Nh_DtE.Location = new System.Drawing.Point(12, 75);
            this.lblTen_Nh_DtE.Name = "lblTen_Nh_DtE";
            this.lblTen_Nh_DtE.Size = new System.Drawing.Size(73, 14);
            this.lblTen_Nh_DtE.TabIndex = 4;
            this.lblTen_Nh_DtE.Text = "Tên tiếng Anh";
            // 
            // lblNh_Cuoi_Dt
            // 
            this.lblNh_Cuoi_Dt.AutoSize = true;
            this.lblNh_Cuoi_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNh_Cuoi_Dt.Location = new System.Drawing.Point(12, 97);
            this.lblNh_Cuoi_Dt.Name = "lblNh_Cuoi_Dt";
            this.lblNh_Cuoi_Dt.Size = new System.Drawing.Size(57, 14);
            this.lblNh_Cuoi_Dt.TabIndex = 4;
            this.lblNh_Cuoi_Dt.Text = "Nhóm cuối";
            // 
            // txtNh_Cuoi_Dt
            // 
            this.txtNh_Cuoi_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtNh_Cuoi_Dt.CheckTextSearched = false;
            this.txtNh_Cuoi_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtNh_Cuoi_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNh_Cuoi_Dt.InputMask = "C,K";
            this.txtNh_Cuoi_Dt.Location = new System.Drawing.Point(123, 94);
            this.txtNh_Cuoi_Dt.Name = "txtNh_Cuoi_Dt";
            this.txtNh_Cuoi_Dt.OldValue = null;
            this.txtNh_Cuoi_Dt.Size = new System.Drawing.Size(23, 20);
            this.txtNh_Cuoi_Dt.TabIndex = 5;
            this.txtNh_Cuoi_Dt.Text = "C";
            this.txtNh_Cuoi_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtNh_Cuoi_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtNh_Cuoi_Dt.Value = "C";
            // 
            // txtNh_Me_Dt
            // 
            this.txtNh_Me_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtNh_Me_Dt.CheckTextSearched = false;
            this.txtNh_Me_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtNh_Me_Dt.EmptyIsValid = true;
            this.txtNh_Me_Dt.FieldDisplay = "Ten_Nh_Dt";
            this.txtNh_Me_Dt.FirstFilter = "Nh_Cuoi_Dt = \'K\'";
            this.txtNh_Me_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNh_Me_Dt.Location = new System.Drawing.Point(123, 116);
            this.txtNh_Me_Dt.MaxLength = 32;
            this.txtNh_Me_Dt.Name = "txtNh_Me_Dt";
            this.txtNh_Me_Dt.OldValue = null;
            this.txtNh_Me_Dt.Size = new System.Drawing.Size(126, 20);
            this.txtNh_Me_Dt.TabIndex = 6;
            this.txtNh_Me_Dt.TableName = "DMNHDT";
            this.txtNh_Me_Dt.TextDisplay = this.txtTen_Nh_Me;
            this.txtNh_Me_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.ItemCode;
            this.txtNh_Me_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.All;
            this.txtNh_Me_Dt.Value = global::SmartSoft.ReportForms.FormVTH02BViewer.txtTen_Nh_Vt_Value;
            // 
            // txtTen_Nh_Me
            // 
            this.txtTen_Nh_Me.BackColor = System.Drawing.SystemColors.Control;
            this.txtTen_Nh_Me.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Nh_Me.CheckTextSearched = false;
            this.txtTen_Nh_Me.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nh_Me.Enabled = false;
            this.txtTen_Nh_Me.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Nh_Me.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Nh_Me.Location = new System.Drawing.Point(255, 119);
            this.txtTen_Nh_Me.Name = "txtTen_Nh_Me";
            this.txtTen_Nh_Me.OldValue = null;
            this.txtTen_Nh_Me.Size = new System.Drawing.Size(250, 13);
            this.txtTen_Nh_Me.TabIndex = 13;
            this.txtTen_Nh_Me.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtTen_Nh_Me.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Nh_Me.Value = global::SmartSoft.ReportForms.FormVTH02BViewer.txtTen_Nh_Vt_Value;
            // 
            // lblNh_Me_Dt
            // 
            this.lblNh_Me_Dt.AutoSize = true;
            this.lblNh_Me_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNh_Me_Dt.Location = new System.Drawing.Point(12, 119);
            this.lblNh_Me_Dt.Name = "lblNh_Me_Dt";
            this.lblNh_Me_Dt.Size = new System.Drawing.Size(51, 14);
            this.lblNh_Me_Dt.TabIndex = 4;
            this.lblNh_Me_Dt.Text = "Nhóm mẹ";
            // 
            // lblNh_Cuoi_Dt0
            // 
            this.lblNh_Cuoi_Dt0.AutoSize = true;
            this.lblNh_Cuoi_Dt0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblNh_Cuoi_Dt0.ForeColor = System.Drawing.Color.Blue;
            this.lblNh_Cuoi_Dt0.Location = new System.Drawing.Point(152, 97);
            this.lblNh_Cuoi_Dt0.Name = "lblNh_Cuoi_Dt0";
            this.lblNh_Cuoi_Dt0.Size = new System.Drawing.Size(202, 14);
            this.lblNh_Cuoi_Dt0.TabIndex = 33;
            this.lblNh_Cuoi_Dt0.Text = "C-Nhóm cuối, K-Không phải là nhóm cuối";
            // 
            // txtNh_PhanTheoDV_Dt
            // 
            this.txtNh_PhanTheoDV_Dt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtNh_PhanTheoDV_Dt.CheckTextSearched = false;
            this.txtNh_PhanTheoDV_Dt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtNh_PhanTheoDV_Dt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtNh_PhanTheoDV_Dt.InputMask = "C,K";
            this.txtNh_PhanTheoDV_Dt.Location = new System.Drawing.Point(331, 28);
            this.txtNh_PhanTheoDV_Dt.Name = "txtNh_PhanTheoDV_Dt";
            this.txtNh_PhanTheoDV_Dt.OldValue = null;
            this.txtNh_PhanTheoDV_Dt.Size = new System.Drawing.Size(23, 20);
            this.txtNh_PhanTheoDV_Dt.TabIndex = 2;
            this.txtNh_PhanTheoDV_Dt.Text = "C";
            this.txtNh_PhanTheoDV_Dt.UserTextLength = SmartSoft.AppInstance.TextControlLength.None;
            this.txtNh_PhanTheoDV_Dt.UserTrimMode = SmartSoft.AppInstance.TextControlTrimMode.Right;
            this.txtNh_PhanTheoDV_Dt.Value = "C";
            // 
            // labelControl1
            // 
            this.labelControl1.AutoSize = true;
            this.labelControl1.Font = new System.Drawing.Font("Arial", 8.25F);
            this.labelControl1.Location = new System.Drawing.Point(238, 31);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new System.Drawing.Size(88, 14);
            this.labelControl1.TabIndex = 36;
            this.labelControl1.Text = "Phân theo đơn vị";
            // 
            // labelControl2
            // 
            this.labelControl2.AutoSize = true;
            this.labelControl2.Font = new System.Drawing.Font("Arial", 8.25F);
            this.labelControl2.ForeColor = System.Drawing.Color.Blue;
            this.labelControl2.Location = new System.Drawing.Point(360, 31);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new System.Drawing.Size(145, 14);
            this.labelControl2.TabIndex = 38;
            this.labelControl2.Text = "C-Dùng riêng, K-Dùng chung";
            // 
            // FormDmNhDtEditor
            // 
            this.AddTitleText = "Thêm mới nhóm đối tượng";
            this.ClientSize = new System.Drawing.Size(522, 172);
            this.Controls.Add(this.labelControl2);
            this.Controls.Add(this.txtNh_PhanTheoDV_Dt);
            this.Controls.Add(this.labelControl1);
            this.Controls.Add(this.lblNh_Cuoi_Dt0);
            this.Controls.Add(this.txtTen_Nh_Me);
            this.Controls.Add(this.txtNh_Me_Dt);
            this.Controls.Add(this.txtNh_Cuoi_Dt);
            this.Controls.Add(this.lblTen_Nh_DtE);
            this.Controls.Add(this.lblNh_Cuoi_Dt);
            this.Controls.Add(this.lblTen_Nh_Dt);
            this.Controls.Add(this.lblNh_Me_Dt);
            this.Controls.Add(this.lblMa_Nh_Dt);
            this.Controls.Add(this.txtTen_Nh_DtE);
            this.Controls.Add(this.txtTen_Nh_Dt);
            this.Controls.Add(this.txtMa_Nh_Dt);
            this.EditTitleText = "Sửa nhóm đối tượng";
            this.FirstFreeCode = "NT1";
            this.Name = "FormDmNhDtEditor";
            this.SecondFreeCode = "NT2";
            this.Text = "Thêm mới nhóm đối tượng";
            this.ThirdFreeCode = "NT3";
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.txtMa_Nh_Dt, 0);
            this.Controls.SetChildIndex(this.txtTen_Nh_Dt, 0);
            this.Controls.SetChildIndex(this.txtTen_Nh_DtE, 0);
            this.Controls.SetChildIndex(this.lblMa_Nh_Dt, 0);
            this.Controls.SetChildIndex(this.lblNh_Me_Dt, 0);
            this.Controls.SetChildIndex(this.lblTen_Nh_Dt, 0);
            this.Controls.SetChildIndex(this.lblNh_Cuoi_Dt, 0);
            this.Controls.SetChildIndex(this.lblTen_Nh_DtE, 0);
            this.Controls.SetChildIndex(this.txtNh_Cuoi_Dt, 0);
            this.Controls.SetChildIndex(this.txtNh_Me_Dt, 0);
            this.Controls.SetChildIndex(this.txtTen_Nh_Me, 0);
            this.Controls.SetChildIndex(this.lblNh_Cuoi_Dt0, 0);
            this.Controls.SetChildIndex(this.labelControl1, 0);
            this.Controls.SetChildIndex(this.txtNh_PhanTheoDV_Dt, 0);
            this.Controls.SetChildIndex(this.labelControl2, 0);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        protected override void OnReset()
        {
            this.txtNh_Cuoi_Dt.ReadOnly = !base.NewChecked;
            base.OnReset();
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_Nh_Dt.Text))
            {
                MessageBox.Show("Chưa nhập mã nhóm đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_Nh_Dt.Text))
            {
                MessageBox.Show("Chưa nhập tên nhóm đối tượng!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Nh_Dt"] = this.txtMa_Nh_Dt.Value;
            localCurrentRow["Ten_Nh_Dt"] = this.txtTen_Nh_Dt.Value;
            localCurrentRow["Ten_Nh_DtE"] = this.txtTen_Nh_DtE.Value;
            localCurrentRow["Nh_Cuoi_Dt"] = this.txtNh_Cuoi_Dt.Value;
            localCurrentRow["Nh_Me_Dt"] = this.txtNh_Me_Dt.Value;
            localCurrentRow["Ten_Nh_Me"] = this.txtTen_Nh_Me.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;            
            localCurrentRow["Ma_Loai3"] = this.txtNh_PhanTheoDV_Dt.Value;
            DmNhDtDataAccess access = new DmNhDtDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Nh_Dt.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Nh_Dt.Value = base.LocalCurrentRow["Ma_Nh_Dt"];
            this.txtTen_Nh_Dt.Value = base.LocalCurrentRow["Ten_Nh_Dt"];
            this.txtTen_Nh_DtE.Value = base.LocalCurrentRow["Ten_Nh_DtE"];
            this.txtNh_Cuoi_Dt.Value = base.LocalCurrentRow["Nh_Cuoi_Dt"];
            this.txtNh_Me_Dt.Value = base.LocalCurrentRow["Nh_Me_Dt"];
            this.txtTen_Nh_Me.Value = base.LocalCurrentRow["Ten_Nh_Me"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];            
            this.txtNh_PhanTheoDV_Dt.Value = base.LocalCurrentRow["Ma_Loai3"];
            base.OnShow();
        }
    }
}

